<template>
  <el-container class="layout-container">
    <el-header class="header">
      <div class="header-left"></div>
      <div class="header-right">
        <span class="admin-name">管理员：{{ uts.token.nickname }}</span>
        <el-button type="text" @click="logout" class="logout-button">退出登录</el-button>
      </div>
    </el-header>
    <el-container>
      <!-- 菜单 -->
      <el-aside width="200px" class="sidebar">
        <el-menu
          active-text-color="#ffd04b"
          background-color="#4169e1"
          text-color="#fff"
          router
          class="menu"
        >
          <el-menu-item index="/merchant/ordere">
            <el-icon><Document /></el-icon> 
            企业管理
          </el-menu-item>
          <el-menu-item index="/merchant/driver">
            <el-icon><UserFilled /></el-icon>
            司机管理
          </el-menu-item>
        </el-menu>
      </el-aside>
      <!-- 界面 -->
      <el-main class="main-content">
        <router-view />
      </el-main>
    </el-container>
  </el-container>
</template>

<script setup>
import {
  Management,
  Promotion,
  UserFilled,
  User,
  Crop,
  EditPen,
  SwitchButton,
  CaretBottom,
  Document,
  Menu as IconMenu,
  Location,
  Setting,
} from "@element-plus/icons-vue";
import { useTokenStore } from '@/stores/token';
import { useRouter } from 'vue-router';

const uts = useTokenStore();
const router = useRouter();

const logout = () => {
  uts.removeToken();
  router.push('/admin');
};

</script>

<style lang="scss" scoped>
.layout-container {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  background-color: #4169e1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  
  .header-left {
    flex: 1;
  }
  
  .header-right {
    .admin-name {
      font-size: 16px;
      color: #f5f5f5;
    }
  }
}

.sidebar {
  background-color: #4169e1;

  .menu {
    height: calc(100vh - 64px); 
    overflow-y: auto; 
  }
}

.main-content {
  padding: 20px;
  background-color: #f9f9f9; 
}

.footer {
  background-color: #f5f5f5;
  font-size: 14px;
  color: #666;
  padding: 10px;
  box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.1);
  text-align: center;
}
</style>